import request from '@/utils/request'

// 查询模型列表
export function listModel(query) {
  return request({
    url: '/act/model/list',
    method: 'get',
    params: query
  })
}

// 保存模型
export function saveModel(data) {
  return request({
    url: '/act/model/save',
    method: 'post',
    data: data
  })
}

// 删除模型
export function delModel(id) {
  return request({
    url: '/act/model/' + id,
    method: 'delete'
  })
}

// 查询模型详细
export function getModel(id) {
  return request({
    url: '/act/model/' + id,
    method: 'get'
  })
}

// 部署流程
export function deployModel(id) {
  return request({
    url: '/act/model/deploy/' + id,
    method: 'post'
  })
}

// 根据流程定义的key获取表单信息
export function getFormInfo(procDefKey) {
  return request({
    url: '/act/model/getFormInfo/' + procDefKey,
    method: 'get'
  })
}

// 校验流程标识是否重复
export function checkKey(key, id, copyModel) {
  var data = {}
  data.key = key
  data.id = id
  data.copyModel = copyModel
  return request({
    url: '/act/model/checkKey/',
    method: 'get',
    params: data
  })
    .then(result => result.code === 200 && result.data)
}

// 根据modelId查询系统审批通知模版详细
export function getWfActModelMsgTemplateByModelId(modelId) {
  return request({
    url: '/msgTemplate/wfActModelMsgTemplate/getInfoByModelId/' + modelId,
    method: 'get'
  })
}

// 保存系统审批通知模版
export function saveWfActModelMsgTemplate(data) {
  return request({
    url: '/msgTemplate/wfActModelMsgTemplate/save',
    method: 'post',
    data: data
  })
}
